import React, { Component } from 'react'
import PropTypes from 'prop-types'
import InputOpenWin from '../InputOpenWin'
import {HTTP, getOrganNo} from "../../../utils";
import { signContractList } from '../../../utils/api'


export default class extends Component {

    constructor(props) {
        super(props)
        this.input = undefined
    }

    componentDidMount() {
        if(this.props.initVal ===  undefined || this.props.initVal === null || this.props.initVal == "") {

        } else {
            HTTP.post(signContractList, {producerOrganNo: this.props.initVal}, () => {
            }, (resp) => {
                const name = ((((resp || {})['data'] || [])[0] || {}))['producerOrganName']
                this.input.setText(name)
            })
        }
    }


    tableSeaField = []

    tableUrl = signContractList

    tableColumn = [{
        title: '厂方名称',
        dataIndex: 'producerOrganName',
        key: 'producerOrganName',
    }, {
        title: '厂方编码',
        dataIndex: 'producerOrganNo',
        key: 'producerOrganNo',
    }]

    tableSeaExtendVal = {
        dealerOrganNo: getOrganNo()
    }

    render = () => {
        return (
            <InputOpenWin
                ref={(e) => {this.input=e}}
                tableTitle="厂方列表"
                tableSeaField={this.tableSeaField}
                tableSeaExtendVal={this.tableSeaExtendVal}
                tableUrl={this.tableUrl}
                tableColumn={this.tableColumn}
                valueField="producerOrganName"
                keyField="producerOrganNo"
                {...this.props}
            />
        )
    }
}
